﻿using System.Collections.Generic;
using System.Data;
using IService.Model;
using IService.DataDLL;
using IService.Data;

namespace IService.Business.Manager
{
	public class UserManager : DTVBaseObject
	{
		public User Login(string username, string userpass)
		{
			return DTVData.UserManager.Login(username, userpass);
		}

		public User GetUserByUserName(string userName)
		{
			User user = new User();
			user.UserName = userName;
			string WhereClause = "[UserName]=\"" + userName + "\"";
			return DTVData.UserManager.GetUserByUserName(user, WhereClause);
		}

		public User GetUserByEmail(string email)
		{
			User user = new User();
			user.Email = email;
			string WhereClause = "[Email]=\"" + email + "\"";
			return DTVData.UserManager.GetUserByEmail(user, WhereClause);
		}

		public User GetUserById(int Id)
		{
			User user = new User();
			user.ID = Id;
			return DTVData.UserManager.GetUserById(user);
		}

		public DataTable GetUserListPagin(PagingEntity pe)
		{
			return DTVData.UserManager.GetUserListPagin(typeof(User), pe);
		}

		public DataTable GetUserByTypeOnsite(int UserTypeId)
		{
			string WhereClause = "[UserTypeId]=" + UserTypeId + " and [ShowWebsite]=true";
			string Order = "[CreateTime] desc";
			return DTVData.UserManager.GetUserByType(typeof(User), WhereClause, Order);
		}

		public DataTable GetUserByType(int UserTypeId)
		{
			string WhereClause = "[UserTypeId]=" + UserTypeId;
			string Order = "[CreateTime] desc";
			return DTVData.UserManager.GetUserByType(typeof(User), WhereClause, Order);
		}

		public DataTable GetUserByYear(int year)
		{
			return DTVData.UserManager.GetUserByYear(typeof(User), year);
		}

		public DataTable GetLatestUserList(int Usernum)
		{
			return DTVData.UserManager.GetLatestUserList(typeof(User), Usernum);
		}

		public bool InsertUser(User user)
		{
			return DTVData.UserManager.InsertUser(user);
		}

		public bool UpdateUser(User user)
		{
			return DTVData.UserManager.UpdateUser(user);
		}

		public bool DeleteUser(int Id)
		{
			User user = new User();
			user.ID = Id;
			return DTVData.UserManager.DeleteUser(user);
		}

		public bool DeleteUserByIds(string Ids)
		{
			string WhereClause = "Id in(" + Ids + ")";
			return DTVData.UserManager.DeleteUserByIds(typeof(User), WhereClause);
		}

	}
}
